﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Aspose.Slides.Pptx;
using System.Drawing;
using Aspose.Slides.Export;
using Aspose.Slides;

namespace PPTUtilities
{
    class ImageUtilities
    {
        public static void AddPictureFrame(PresentationEx pres, int SlidePosition, int Xposition, int YPosition, float Height, float Width, Image img)
        {
            //Get the first slide
            SlideEx sld = pres.Slides[SlidePosition];

            //Instantiate the ImageEx class
            ImageEx imgx = pres.Images.AddImage(img);
            //Add Picture Frame with height and width equivalent of Picture
            sld.Shapes.AddPictureFrame(ShapeTypeEx.Rectangle, Xposition, YPosition,Width, Height, imgx);
            ShapeEx shp = sld.Shapes.OfType<ShapeEx>().Last();
            shp.LineFormat.FillFormat.FillType = FillTypeEx.NoFill;
        }
        public static void AddPictureFrameWithLink(PresentationEx pres, int SlidePosition, int Xposition, int YPosition, float Height, float Width, Image img, int screenPos)
        {
            //Get the first slide
            SlideEx sld = pres.Slides[SlidePosition];

            //Instantiate the ImageEx class
            ImageEx imgx = pres.Images.AddImage(img);
            //Add Picture Frame with height and width equivalent of Picture
            sld.Shapes.AddPictureFrame(ShapeTypeEx.Rectangle, Xposition, YPosition, Width, Height, imgx);
            ShapeEx shp = sld.Shapes.OfType<ShapeEx>().Last();
            shp.LineFormat.FillFormat.FillType = FillTypeEx.NoFill;
             HyperlinkEx HLink = new HyperlinkEx(pres.Slides[screenPos]);
             shp.HLinkClick = HLink;
        }
        public static void RemoveShapeBorder(PresentationEx pres, int SlidePosition)
        {
            //Get the first slide
            SlideEx sld = pres.Slides[SlidePosition];
            foreach(ShapeEx shp in sld.Shapes.OfType<ShapeEx>())
            {
                if (shp.LineFormat!=null)
                shp.LineFormat.FillFormat.FillType = FillTypeEx.NoFill;
            }
        }

    }
}
